package com.huawei.hwid.vermanager;

import android.content.Context;
import com.huawei.secure.android.common.ssl.SecureSSLSocketFactory;
import com.huawei.secure.android.common.ssl.SecureX509TrustManager;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;

public final class e {
    private static e a = null;

    public static final e a() {
        e eVar;
        synchronized (e.class) {
            if (a == null) {
                a = new e();
            }
            eVar = a;
        }
        return eVar;
    }

    public SSLSocketFactory a(Context context) throws IOException {
        com.huawei.hwid.core.d.b.e.b("NetworkClient", " getSSLSocketFactory HmsTrustManagerFactory", true);
        try {
            return SecureSSLSocketFactory.getInstance(context);
        } catch (NoSuchAlgorithmException e) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "exception in getSSLSocketFactory, NoSuchAlgorithmException", true);
            throw new IOException("getSSLSocketFactory");
        } catch (KeyManagementException e2) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "exception in getSSLSocketFactory, KeyManagementException", true);
            throw new IOException("getSSLSocketFactory");
        } catch (KeyStoreException e3) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "exception in getSSLSocketFactory, KeyStoreException", true);
            throw new IOException("getSSLSocketFactory");
        } catch (CertificateException e4) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "exception in getSSLSocketFactory, CertificateException", true);
            throw new IOException("getSSLSocketFactory");
        } catch (IllegalAccessException e5) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "exception in getSSLSocketFactory, IllegalAccessException", true);
            throw new IOException("getSSLSocketFactory");
        }
    }

    public X509TrustManager b(Context context) throws IOException {
        com.huawei.hwid.core.d.b.e.b("NetworkClient", " getX509TrustManager SecureX509TrustManager", true);
        try {
            return new SecureX509TrustManager(context);
        } catch (Throwable e) {
            com.huawei.hwid.core.d.b.e.d("NetworkClient", "Failed to new SecureX509TrustManager instance", true);
            throw new IOException("Failed to get SecureX509TrustManager instance", e);
        }
    }

    public HostnameVerifier a(String str) {
        com.huawei.hwid.core.d.b.e.b("NetworkClient", " getSafeIPHostnameVerifier SafeIPHostnameVerifier", true);
        return SecureSSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
    }
}
